package ControlLayer;
import java.util.ArrayList;
import ModelLayer.*;
//model layer package has to be imported

/**
 * Controller class for the address book
 * 
 * @author (kbh) 
 * @version (2005.03.31)
 * (FEN): 2006.03.21: Some changes to the architecture in order to assure layering
 *                    and loose coupling
 */


public class AddressBookCtr
{

    private AddressBook addressBook;
    //Address container is to be passed as parameter from the main controller
    public AddressBookCtr()
    {
      addressBook = addressBook.getInstance();
    }

    //Dummy implementation: after implementing the model layer 
    //objects of class Person are to be returned, not String
    public Person getPerson(int searchId)
    {
        return addressBook.findPersonId(searchId);
        
    }

    public void createPerson(int id, String name, String address, String zipCode, String city, String phoneNumber)
    {   
        Person newPerson = new Person(id, name, address, zipCode, city, phoneNumber);
        addressBook.addPerson(newPerson);
    }

    public void deletePerson(int searchId)
    {
        addressBook.removePerson(searchId);
    }

    public void updatePerson(int searchId, int id, String name, String address, String zipCode, String city, String phoneNumber)
    {
        addressBook.changePerson(searchId, id, name, address, zipCode, city, phoneNumber);
    }

    public void listAllPersons()
    {
        addressBook.listPersonInfo();
    }
    
    public void listPersonInfo(int searchId)
    {
        addressBook.showPersonInfo(searchId);
    }
    
}

